import { post, BaseRes } from "../libs/request";
import { Relevance } from "../models/enums";
import { IBooks, IUser, Remark } from "../models/types";
// API路径前缀
const PREFIX = "/api/remark";

interface Remarklist extends BaseRes {
  data: { list: Remark[]; total: number };
}

interface RemarkContent extends BaseRes {
  data: Remark;
}

export async function add(
  bookId: string,
  content: string,
  rate: number,
  dingdanId?: string
) {
  const res = await post<RemarkContent>(PREFIX + "/add", {
    bookId,
    content,
    rate,
    dingdanId,
  });
  return res.data;
}

export async function list(
  bookId: string,
  skip: number,
  limit: number,
  flag: boolean,
  token?: string
) {
  const res = await post<Remarklist>(
    PREFIX + "/list",
    {
      bookId,
      skip,
      limit,
      flag,
    },
    token
  );
  return res.data;
}

export async function thumb(remarkId: string, flag: boolean) {
  const res = await post<BaseRes>(PREFIX + "/deal/thumb", {
    remarkId,
    flag,
  });
  return res.data;
}
